const getJSON = function (url, cb) {
  var script = document.createElement('script')
  script.src = url
  var cbName = url.match(/callback=([^&]+)/)[1]
  document.body.append(script)

  // cbName 和 cb 结合在一起成为下面的样子，并且是一个全局函数呢

  window[cbName] = cb // ->  window.hello = function(res){}

  script.onload = function () {
    this.remove()
  }
}
export default getJSON
